#include "IceStreamWrapper.h"

OutputStreamWrapper::OutputStreamWrapper(IceProxy::Ice::Object* objPrx)	
{
	_imp = Ice::createOutputStream(objPrx->ice_getCommunicator());
    _imp->startEncapsulation();
}

void OutputStreamWrapper::writeBool( bool v)
{
	_imp->write(v);
}

void OutputStreamWrapper::writeByte( Ice::Byte v)
{
	_imp->write(v);
}

void OutputStreamWrapper::writeShort(Ice::Short v) 
{
	_imp->write(v);
}
void OutputStreamWrapper::writeInt(Ice::Int v)
{
	_imp->write(v);
}
void OutputStreamWrapper::writeLong(Ice::Long v)
{
	_imp->write(v);
}
void OutputStreamWrapper::writeFloat(Ice::Float v) 
{
	_imp->write(v);
}
void OutputStreamWrapper::writeDouble(Ice::Double  v) 
{
	_imp->write(v);
}
void OutputStreamWrapper::writeString(const ::std::string& v) 
{
	_imp->write(v);
}


void OutputStreamWrapper::writeBoolSeq(const ::std::vector<bool>& v)
{
	_imp->write(v);
}    
void OutputStreamWrapper::writeByteSeq(const ::std::vector<Ice::Byte>& v)
{
	_imp->write(v);
}
void OutputStreamWrapper::writeShortSeq(const ::std::vector<Ice::Short>& v)
{
	_imp->write(v);
}
void OutputStreamWrapper::writeIntSeq(const ::std::vector<Ice::Int>& v) 
{
	_imp->write(v);
}
void OutputStreamWrapper::writeLongSeq(const ::std::vector<Ice::Long>& v) 
{
	_imp->write(v);
}
void OutputStreamWrapper::writeFloatSeq(const ::std::vector<Ice::Float>& v)
{
	_imp->write(v);
}
void OutputStreamWrapper::writeDoubleSeq(const ::std::vector<Ice::Double>& v) 
{
	_imp->write(v);
}
void OutputStreamWrapper::writeStringSeq(const ::std::vector< ::std::string>& v) 
{
	_imp->write(v);
}

void OutputStreamWrapper::writeProxy(const Ice::ObjectPrx& v) 
{
	_imp->writeProxy(v);
}

std::vector<Ice::Byte>* OutputStreamWrapper::getData()
{
	std::vector<Ice::Byte>* data = new std::vector<Ice::Byte>();
    _imp->endEncapsulation();
	_imp->finished(*data);
	return data;
}

///////////////////////////////////////////////////////////////////////////////////////////////
InputStreamWrapper::InputStreamWrapper(IceInternal::BasicStream* is)
{
    _is = is;
}

InputStreamWrapper::~InputStreamWrapper()
{
}

bool InputStreamWrapper::readBool()
{
    bool ret;
    _is->read(ret);
    
    return ret;
}

Ice::Byte InputStreamWrapper::readByte()
{
    Ice::Byte ret;
    _is->read(ret);
    
    return ret;
}


Ice::Short InputStreamWrapper::readShort()
{
    Ice::Short ret;
    _is->read(ret);
    
    return ret;
}


Ice::Int InputStreamWrapper::readInt()
{
    Ice::Int ret;
    _is->read(ret);
    
    return ret;
}

Ice::Long InputStreamWrapper::readLong()
{
    Ice::Long ret;
    _is->read(ret);
    
    return ret;
}


Ice::Float InputStreamWrapper::readFloat()
{
    Ice::Float ret;
    _is->read(ret);
    
    return ret;
}

Ice::Double InputStreamWrapper::readDouble()
{
    Ice::Double ret;
    _is->read(ret);
    
    return ret;
}


std::string InputStreamWrapper::readString(bool b)
{
    std::string ret;
    _is->read(ret, b);
    
    return ret;
}


Ice::ObjectPrx InputStreamWrapper::readProxy()
{
    Ice::ObjectPrx ret;
    _is->read(ret);
    
    return ret;
}



std::vector<int> InputStreamWrapper::readIntSeq()
{
    std::vector<int> ret;
    _is->read(ret);
    
    return ret;
}

std::vector<std::string> InputStreamWrapper::readStringSeq()
{
    std::vector<std::string> ret;
    _is->read(ret);
    
    return ret;
}

std::vector<Ice::Long> InputStreamWrapper::readLongSeq()
{
    std::vector<Ice::Long> ret;
    _is->read(ret);
    
    return ret;
}